#include <windows.h>
#include "resource.h"
#include <stdio.h>
#include <tchar.h>
#pragma comment (linker,"/SUBSYSTEM:WINDOWS")
DialogCmd(HWND hwndDlg,WPARAM wParam,LPARAM lParam)
{
	switch(LOWORD(wParam))
	{
	case IDOK:
        EndDialog(hwndDlg,IDOK);
	}
}
DialogInit(HWND hwndDlg,WPARAM wParam,LPARAM lParam)
{
	/*At first ,set the Dialog Icon(IDI_ICON1).*/
	HICON hIcon = LoadIcon((HINSTANCE) GetWindowLongPtr(hwndDlg, GWLP_HINSTANCE),MAKEINTRESOURCE(IDI_ICON1));
	SendMessage(hwndDlg, WM_SETICON, TRUE,(LPARAM)hIcon);
    SendMessage(hwndDlg, WM_SETICON, FALSE, (LPARAM)hIcon);
	/*Add other initialize code here*/
}
INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_INITDIALOG:
		DialogInit(hwndDlg,wParam,lParam);
		return TRUE;
	case WM_COMMAND:
		DialogCmd( hwndDlg, wParam,lParam);
		return TRUE;
	case WM_CLOSE:
		EndDialog(hwndDlg,IDOK);
		break;
	default:
		break;
	}		
	return FALSE;
}
int WINAPI _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
	DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,DialogProc);
	return 1;
}

